<template>
  <div class="login">
    <el-form class="form" :model="form" :rules="rules" ref="form">
      <img src="@/assets/common/login-logo.png" alt="" class="img" />
      <el-form-item prop="mobile">
        <el-input prefix-icon="el-icon-user-solid" v-model="form.mobile">
        </el-input>
      </el-form-item>
      <el-form-item prop="password">
        <el-input
          prefix-icon="el-icon-lock"
          show-password
          v-model="form.password"
        >
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button class="btn" @click="btnClick">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data () {
    return {
      form: {
        mobile: '13800000002',
        password: '123456'
      },
      rules: {
        mobile: [{ required: true, message: '必填', trigger: 'change' }],
        password: [{ required: true, message: '必填', trigger: 'change' }]
      }
    }
  },
  methods: {
    btnClick () {
      this.$refs.form.validate(async result => {
        if (result) {
          await this.$store.dispatch('user/toLogin', this.form)
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.login {
  width: 100%;
  height: 100%;
  background-image: url(~@/assets/common/logBg.png);
  background-size: 100% 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  .form {
    width: 500px;
    height: 400px;
    display: flex;
    flex-direction: column;
    .btn {
      width: 100%;
      color: #fff;
      background-color: #407ffe;
    }
    .img {
      margin-bottom: 30px;
    }
  }
}
</style>
